package com.jucai.pppeiyouclient.adapter;

import android.content.Context;
import android.view.View;

import com.jucai.pppeiyouclient.R;
import com.jucai.pppeiyouclient.base.CommonRecyclerViewAdapter;
import com.jucai.pppeiyouclient.bean.AccompanyRecordBean;

import java.util.List;

/**
 * Created by Kuky on 2017-05-06.
 */

public class AccompanyRecordAdapter extends CommonRecyclerViewAdapter<AccompanyRecordBean> {
    public AccompanyRecordAdapter(Context context, List<AccompanyRecordBean> data) {
        super(context, data);
    }

    @Override
    public void bindHolder(CommonHolder holder, AccompanyRecordBean accompanyRecordBean) {
        holder.setImage(R.id.acc_record_img, accompanyRecordBean.getMember_avatar(), 60, 60);
        holder.setText(R.id.acc_record_name, accompanyRecordBean.getMember_realname());
//        holder.setText(R.id.acc_record_len, "时长：" + accompanyRecordBean.getLen() + "h");
        holder.itemView.findViewById(R.id.acc_record_len).setVisibility(View.GONE);
        holder.setText(R.id.acc_record_meet, "见面地点：" + accompanyRecordBean.getAddress());
        holder.setText(R.id.acc_record_date, "活动日期：" + accompanyRecordBean.getTorder_start_time());
        holder.setText(R.id.acc_record_evaluate, "评语：" + accompanyRecordBean.getEvaluate());

        List<String> imageUrls = accompanyRecordBean.getImglist();
        if (imageUrls == null || imageUrls.size() == 0) {
            holder.setGone(R.id.acc_record_ll);
        } else {
            if (imageUrls.size() == 1) {
                holder.setImage(R.id.acc_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setGone(R.id.acc_record_pic_02);
                holder.setGone(R.id.acc_record_pic_03);
                holder.setGone(R.id.acc_record_pic_04);
            } else if (imageUrls.size() == 2) {
                holder.setImage(R.id.acc_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setImage(R.id.acc_record_pic_02, imageUrls.get(1), 45, 35);
                holder.setGone(R.id.acc_record_pic_03);
                holder.setGone(R.id.acc_record_pic_04);
            } else if (imageUrls.size() == 3) {
                holder.setImage(R.id.acc_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setImage(R.id.acc_record_pic_02, imageUrls.get(1), 45, 35);
                holder.setImage(R.id.acc_record_pic_03, imageUrls.get(2), 45, 35);
                holder.setGone(R.id.acc_record_pic_04);
            } else if (imageUrls.size() >= 4) {
                holder.setImage(R.id.acc_record_pic_01, imageUrls.get(0), 45, 35);
                holder.setImage(R.id.acc_record_pic_02, imageUrls.get(1), 45, 35);
                holder.setImage(R.id.acc_record_pic_03, imageUrls.get(2), 45, 35);
                holder.setImage(R.id.acc_record_pic_04, imageUrls.get(3), 45, 35);
            }
        }
    }

    @Override
    protected int getItemType(int position) {
        return 0;
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_accompany_record_layout;
    }
}
